/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.midlet.*;

/**
 * @author USER
 */
public class NinjaRunMidlet extends MIDlet implements CommandListener {

    protected Display display;      //reference to display
    private NinjaRunCanvas canvas;
    private Command cmdExit;

    public NinjaRunMidlet() {
        display = Display.getDisplay(this);

        // create game canvas and exit command
        if ((canvas = new NinjaRunCanvas(this)) != null) {
            cmdExit = new Command("Exit", Command.EXIT, 0);
            canvas.addCommand(cmdExit);
            canvas.setCommandListener(this);
        }
    }

    public void startApp() {
        if (canvas != null) {
            display.setCurrent(canvas);
            canvas.start();
        }
    }

    public void pauseApp() {
    }

    public void destroyApp(boolean unconditional) {
        canvas.stop();
    }

    public void commandAction(Command c, Displayable d) {
        if (c == cmdExit) {
            destroyApp(true);
            notifyDestroyed();
        }
    }

    public void exit() {
        canvas.stop();
        destroyApp(true);
        notifyDestroyed();
    }

    public void showMenuCanvas() {
        
    }
}
